/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package kythuatregex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author anh_yeu_em_nhieu_lam
 */
public class ReplaceTextWithRegex {

    public ReplaceTextWithRegex() {
        Pattern mypattern = Pattern.compile("(.*)\\s+(.*)\\s+(.*)");
        String mystring = "I Love You";
        Matcher matcher = mypattern.matcher(mystring);
        if(matcher.find()){
            mystring = matcher.replaceAll("$3 $2 $1 ");//Chú ý phải gán xâu lại để thay đổi xâu
            System.out.print(mystring);
        }
    }
    public static void main(String arg[]){
            new ReplaceTextWithRegex();
    }
}
/*
You Love I 
 * */